package com.warm.middle.redis;

import com.warm.middle.pojo.SysUser;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Date: 2019/11/26 14:17
 * @Author: LChuang
 * @Description:
 */
@RestController
@RequestMapping("/redis")
public class RedisController {

    private static int EXPIRE_TIME = 60;

    @Resource
    private RedisUtil redisUtil;

    @RequestMapping("/set")
    public String redisSet(){
        SysUser user = new SysUser();
        user.setAge(20);
        user.setName("warm");
        redisUtil.set("user", user);
        return "success";
    }

    @RequestMapping("/get")
    public Object redisGet(){
        return redisUtil.get("user");
    }

    @RequestMapping("/expire")
    public boolean expire(){
        return redisUtil.expire("user", EXPIRE_TIME);
    }
}
